
import { IframeViewMode } from '@/types/iframeViewMode'
import { defineStore } from 'pinia'

export interface WikiState {
  wikiId: string | '' | null;
  documentId: string | '' | null;
  iframeViewMode: IframeViewMode | string,
  creator: string | '' | null;
  preview: boolean;
}

export const useWikiStore = defineStore('wiki', {
  state: (): WikiState => ({
    wikiId: '', // 知识库id
    documentId: '',
    iframeViewMode: IframeViewMode.STANDARD,
    creator: '',
    preview: false
  }),

  actions: {
    setWikiInfo(
      wikiId:WikiState['wikiId'], 
      documentId: WikiState['documentId'],
      iframeViewMode: WikiState['iframeViewMode']
    ) {
      this.wikiId = wikiId
      this.documentId = documentId ?? ''
      this.iframeViewMode = iframeViewMode
    },
    setCreator(creator: WikiState['creator']) {
      this.creator = creator
    },
    setPreview(preview: WikiState['preview']) {
      this.preview = preview
    }
  },
})